package com.sky.config;

import com.sky.properties.MinIoProperties;
import com.sky.utils.MinIoUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.StringRedisSerializer;

/**
 * minio配置类
 */
@Configuration
@Slf4j
public class RedisConfiguration {
    @Bean
    @ConditionalOnMissingBean //条件对象当没有这个类的时候就会去创建此类
    public RedisTemplate redisTemplate(RedisConnectionFactory redisConnectionFactory) {
        log.info("Redis初始化...");
        RedisTemplate redisTemplate = new RedisTemplate();
        redisTemplate.setConnectionFactory(redisConnectionFactory);//设置redis连接工厂对象
        redisTemplate.setKeySerializer(new StringRedisSerializer());//设置redis 序列号
        log.info("redis结果" + redisTemplate);
        return redisTemplate;
    }
}
